#pragma once
/***********************************************************************************************
COPYRIGHT 2011 Mafahir Fairoze

This file is part of Neural++.
(Project Website : http://mafahir.wordpress.com/projects/neuralplusplus)

Neural++ is a free software. You can redistribute it and/or modify it under the terms of
the GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.

Neural++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License <http://www.gnu.org/licenses/> for more details.

***********************************************************************************************/
#include "../ISynapse.h"
#include "PositionNeuron.h"
#include "KohonenConnector.h"
namespace NeuralPlusPlus
	{
	namespace Core
		{
		namespace SOM

			{
			/// <summary>
			/// A Kohonen Synapse is used to connect a neuron to a Position Neuron. It propagates the data
			/// from input neuron to an output position neuron and self-organizes its weights to match the
			/// input.
			/// </summary>
			class KohonenSynapse : public ISynapse
				{

				/// <summary>
				/// Creates a new Kohonen Synapse connecting the given neurons
				/// </summary>
				public: KohonenSynapse(PositionNeuron *sourceNeuron, PositionNeuron *targetNeuron, KohonenConnector *parent);

						/// <summary>
						/// Propagates the data from source neuron to the target neuron
						/// </summary>
				public: void Propagate();

						/// <summary>
						/// Optimizes the weight to match the input
						/// </summary>
				public: void OptimizeWeight(double learningFactor);

						/// <summary>
						/// Adds small random noise to weight of this->synapse so that the network deviates from
						/// its local optimum position (a local equilibrium state where further learning is of
						/// no use)
						/// </summary>
				public: void Jitter(double jitterNoiseLimit);
				};
			}

		}
	}